import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

labels = ["第四周","第五周", "第六周",]
colors = ['red', 'orange', 'yellow']
forth_absence = [3, 2, 2, 2, 2, 1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Fifth_absence = [3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]
Sixth_absence = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0.5]
average_absence1 = sum(forth_absence) / len(forth_absence)
average_absence2 = sum(Fifth_absence) / len(Fifth_absence)
average_absence3 = sum(Sixth_absence) / len(Sixth_absence)
sizes = [average_absence1, average_absence2, average_absence3]
explode = [0, 0, 0.1]
plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=140)
plt.title("缺勤次数分析")
plt.axis('equal')
plt.savefig(r"D:\pycharm\python study\图像保存2.png")
